package com.project.weimi.adapter;

import java.util.List;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class HomeFragmentViewPagerAdapter extends PagerAdapter{

	private Context context;
	private List<ImageView> list;
	
	public HomeFragmentViewPagerAdapter(Context context, List<ImageView> list) {
		super();
		this.context = context;
		this.list = list;
	}
	
	@Override
	public int getCount() {
		return Integer.MAX_VALUE;
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == arg1;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		View view = list.get(position % list.size());
		container.removeView(view);
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		View view = list.get(position % list.size());
		container.addView(view);
		return view;
	}
	
}
